import http from "../request";
const apibase = "/api/RoleResourceControllers"
import qs from 'qs'

//获取全部权限列表
var GetResourceToList = function() {
	const datas = qs.stringify()
	return new Promise((resolve, reject) => {
		http.post(apibase + `/GetResource`)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}

//获取已关联权限列表
var GetResourceToRoleId = function(data) {
	const datas = qs.stringify(data)
	return new Promise((resolve, reject) => {
		http.post(apibase + `/GetResourceToRoleId?${datas}`)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}
//获取未关联权限列表
var GetNoResourceToRoleId = function(data) {
	const datas = qs.stringify(data)
	return new Promise((resolve, reject) => {
		http.post(apibase + `/GetNoResourceToRoleId?${datas}`)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}
//新增关联
var InsertRoleResource = function(data) {
	return new Promise((resolve, reject) => {
		http.post(apibase + `/InsertRoleResource`, data)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}

//删除关联
var DeleteRoleResource = function(data) {
	return new Promise((resolve, reject) => {
		http.post(apibase + `/DeleteRoleResource`, data)
			.then(res => {
				resolve(res)
			})
			.catch(error => {
				reject(error);
			})
	});
}

export {
	GetResourceToList,
	GetResourceToRoleId,
	GetNoResourceToRoleId,
	InsertRoleResource,
	DeleteRoleResource,
}
